home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 4976 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  3.1 KB

  1. Path: news.mindlink.net!news
  2. From: genew@mindlink.bc.ca (Gene Wirchenko)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: What does the -O option do???!!!
  5. Date: Sun, 11 Feb 1996 21:30:34 GMT
  6. Organization: MIND LINK! - British Columbia, Canada
  7. Message-ID: <4flna0$qe@fountain.mindlink.net>
  8. References: <4ehger$cj9@mark.ucdavis.edu> <823827008snz@genesis.demon.co.uk> <4fiphrINNrvr@keats.ugrad.cs.ubc.ca> <9602102332.AA09466@dxmint.cern.ch> <4flhrhINNtj@keats.ugrad.cs.ubc.ca>
  9. NNTP-Posting-Host: line202.nwm.mindlink.net
  10. X-Newsreader: Forte Free Agent 1.0.82
  11.  
  12. c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku) wrote:
  13.  
  14. >In article <9602102332.AA09466@dxmint.cern.ch>,
  15. >Dan Pop  <danpop@mail.cern.ch> wrote:
  16. >>c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku) writes:
  17. >>
  18. >>>... as long as it is not hard-coded to treat identifiers like "free" specially. 
  19. >>
  20. >>A compiler is free to treat identifiers like "free" specially after the
  21. >>relevant header has been included.
  22. >>
  23. >>>If you write your own free() with different semantics, you would not want the
  24. >>>compiler messing with that. 
  25. >>
  26. >>If you write your own free() you invoke undefined behaviour and you can't
  27. >>expect the compiler to behave in a sensible way.  The implementation 
  28. >>namespace is a big taboo in C.
  29.  
  30. >Are you serious? What if I'm writing a little embedded kernel that doesn't use
  31. >anything resembling the standard C library, and I use free() for something
  32. >quite different?
  33.  
  34.      If a compiler had that sort of optimization, I can easily imagine
  35. a switch for turning it off:
  36.           cc thingie.c -nostdlibuse
  37. or
  38.           #pragma nostdlibuse
  39.  
  40. >This is truly silly. The standard may say one thing, but it's despicable to
  41. >actually implement a compiler that treats free() specially. There is nothing in
  42. >the semantics of free() that requires special treatment in order to do its job.
  43.  
  44.      This is truly silly.  Of course, there could be.  It is
  45. implementation defined as to what it would be.  It might happen if you
  46. "...use free() for something quite different...".
  47.  
  48. >For one thing, malloc() is far from a perfect allocation scheme, so why give it
  49. >preferential treatment? I might design my own library which uses allocation
  50. >handles, and performs heap compaction, for instance.
  51.  
  52.      Alright, alright, so you're you're brilliant and your new memory
  53. allocation scheme makes you worthy of the Nobel Prize!
  54.      Question: are you really going to call it malloc()?
  55.  
  56. >>>It's just another function, after all.
  57. >>
  58. >>No, it isn't.  Have a look at the standard.
  59.  
  60. >I just had a look at the sources for my standard library. It sure looks like a
  61. >function to me. (Walks like a duck, quacks like a duck, ... )
  62.  
  63.      It is.  It is a Standard defined function.  Now, take another
  64. look at the sources for your standard library.  See any of your app
  65. code in there?  If not, why do you suppose that would be?
  66.  
  67. >I wonder whether the seats of that ANSI commitee were actually populated by
  68. >programmers.
  69. >-- 
  70.  
  71.      Sure, but they obviously weren't of your religious beliefs, so
  72. flame 'em all!  <G>
  73.  
  74. Sincerely,
  75.  
  76. Gene Wirchenko
  77.  
  78. C Pronunciation Guide:
  79.      y=x++;     "wye equals ex plus plus semicolon"
  80.      x=x++;     "ex equals ex doublecross semicolon"
  81.  
  82.